<h1 class="crayons-title mb-3">Moderator Actions</h1>
<div class="mb-6">
  <%= search_form_for @q, url: admin_moderator_actions_path, class: "inline-flex" do |f| %>
    <%= f.label :user_username_cont, "User", class: "screen-reader-only" %>
    <%= f.search_field :user_username_cont, aria: { label: "Search" }, placeholder: "User", class: "crayons-textfield mr-2" %>
    <%= f.submit "Search", class: "crayons-btn" %>
  <% end %>
</div>

<%= paginate @moderator_actions %>

<table class="crayons-table" width="100%">
  <thead>
    <tr>
      <th scope="col">ID</th>
      <th scope="col">User</th>
      <th scope="col">Action</th>
      <th scope="col">Data</th>
      <th scope="col">
        <%= tag.span(sort_link(@q, :created_at, "Date")) %>
      </th>
    </tr>
  </thead>
  <tbody class="crayons-card">
    <% @moderator_actions.each do |action| %>
      <tr>
        <td class="whitespace-nowrap"><%= action.id %></td>
        <td><%= link_to(action.user.username, admin_user_path(action.user_id)) if action.user %></td>
        <td><%= "#{action.data['action'].humanize} #{action.data['controller'].humanize.singularize.titleize}" if action.data.present? %></td>
        <td class="mod-actions__data"><%= action.data %></td>
        <td><%= action.created_at %></td>
      </tr>
    <% end %>
  </tbody>
</table>

<%= paginate @moderator_actions %>
